/*
** basics.c for basics in /home/comet_a//afs/local/maths/101vecteur
** 
** Made by alexandre comet
** Login   <comet_a@epitech.net>
** 
** Started on  Fri Nov 18 14:10:05 2011 alexandre comet
** Last update Fri Nov 18 17:01:12 2011 alexandre comet
*/

#include	<unistd.h>

void            my_putchar(char c)
{
  write(1, &c, 1);
}

void		my_put_nbr(int nb)
{
  if (nb < 0)
    {
      my_putchar('-');
      nb = -nb;
    }
  if (nb > 9)
    {
      my_put_nbr(nb / 10);
    }
  return (my_putchar('0' + nb % 10));
}

int             my_getnbr(char *str)
{
  int           result;
  int           puiss;

  result = 0;
  puiss = 1;
  while (('-' == (*str)) || ((*str) == '+'))
    {
      if (*str == '-')
        puiss = puiss * -1;
      str++;
    }
  while ((*str >= '0') && (*str <= '9'))
    {
      result = (result * 10) + ((*str) - '0');
      str++;
    }
  return (result * puiss);
}
